package com.loong.system.handler;

import com.loong.common.utils.TransformUtils;
import com.loong.system.business.SystemConfigTypeBusiness;
import com.loong.system.common.backend.param.SystemConfigKeyParam;
import com.loong.system.common.backend.param.SystemConfigKeyQueryParam;
import com.loong.system.common.backend.param.SystemConfigTypeParam;
import com.loong.system.common.backend.result.SystemConfigKeyResult;
import com.loong.system.common.backend.result.SystemConfigTypeResult;
import com.loong.system.model.SystemConfigKey;
import com.loong.system.model.SystemConfigType;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class SystemConfigTypeHandler {
    @Resource
    private SystemConfigTypeBusiness systemConfigTypeBusiness;


    /**
     * 保存配置类型
     * @param param
     */
    public void save(SystemConfigTypeParam param){
        systemConfigTypeBusiness.save(TransformUtils.transform(param, SystemConfigType.class));
    }


    /**
     * 更新配置类型
     * @param param
     */
    public void update(SystemConfigTypeParam param){
        systemConfigTypeBusiness.updateByPrimaryKeySelective(TransformUtils.transform(param, SystemConfigType.class));
    }

    /**
     * 查询所有配置类型
     *
     * @return
     */
    public List<SystemConfigTypeResult> queryConfigTypeAll(){
        return TransformUtils.transformList(systemConfigTypeBusiness.findAll(),SystemConfigTypeResult.class);
    }

    /**
     *根据id删除配置类型
     * @param id 配置类型的id
     */
    public void deleteConfigTypeById(Long id){
        systemConfigTypeBusiness.deleteById(id);
    }




}
